package crp.core.course.domain.repositories;

import com.qwlabs.lang.C2;
import crp.core.course.domain.models.CourseAttributesEntity;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import io.quarkus.panache.common.Parameters;

import javax.enterprise.context.ApplicationScoped;
import java.util.Set;
import java.util.stream.Stream;

@ApplicationScoped
public class CourseAttributesRepository implements PanacheRepositoryBase<CourseAttributesEntity, String> {
    public Stream<CourseAttributesEntity> findByCourseIds(Set<String> courseIds) {
        if (C2.isEmpty(courseIds)) {
            return Stream.empty();
        }
        return find("course.id in (:courseIds)", Parameters.with("courseIds", courseIds)).stream();
    }
}
